{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0ba083d2",
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "from vocos import Vocos\n",
    "import torchaudio\n",
    "\n",
    "vocos = Vocos.from_pretrained(\"charactr/vocos-encodec-24khz\")\n",
    "\n",
    "bandwidth_id = torch.tensor([3])  # 12 kbps\n",
    "\n",
    "y, sr = torchaudio.load(\"./samples/konichihaaaaaaaaaa.wav\")\n",
    "if y.size(0) > 1:  # mix to mono\n",
    "    y = y.mean(dim=0, keepdim=True)\n",
    "y = torchaudio.functional.resample(y, orig_freq=sr, new_freq=24000)\n",
    "\n",
    "with torch.no_grad():\n",
    "    y_hat = vocos(y, bandwidth_id=bandwidth_id)\n",
    "\n",
    "torchaudio.save(\"samples/rap_base_vocos.wav\", y_hat, 24000)\n",
    "\n",
    "import IPython.display as ipd\n",
    "ipd.Audio(\"samples/rap_base_vocos.wav\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
